import {createBrowserRouter, Navigate, RouterProvider} from 'react-router-dom';
import BlogPage from './BlogPage';
import ArticleDetail from './ArticleDetail';
import LoginPage from './LoginPage';
import PrivateRoute from './PrivateRoute';
import ArticleView from "./ArticleView";
import BlogViewPage from "./BlogViewPage";

const router = createBrowserRouter([
    { path: '/login', element: <LoginPage /> },
    { path: '/blogs/page', element: <PrivateRoute><BlogPage /></PrivateRoute> },
    { path: '/blogs/view/page', element: <PrivateRoute><BlogViewPage /></PrivateRoute> }, // 现在在白名单里，会直接放行
    { path: '/article/detail/:id', element: <PrivateRoute><ArticleDetail /></PrivateRoute> },
    { path: '/article/view/:id', element: <PrivateRoute><ArticleView /></PrivateRoute> },
    { path: '/', element: <Navigate to="/blogs/page" /> }
]);

const AppRouter = () => {
    return <RouterProvider router={router} />;
};

export default AppRouter;